package day_2022_4_to_7.day48;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

/**
 * 查找单词兄弟
 * @author haomin
 * @date 2022/07/07 11:02
 **/
public class Day45_2_FindWordBrother {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        while(in.hasNext()){
            int num = in.nextInt();
            String[] dest = new String[num];
            for(int i = 0;i < num;i++){
                dest[i] = in.next();
            }

            String target = in.next();
            int indext = in.nextInt();
            char[] data = target.toCharArray();
            Arrays.sort(data);
            ArrayList<String> broWords = new ArrayList<>();

            for(String str : dest){
                char[] word = str.toCharArray();
                Arrays.sort(word);
                // 判断两单词是否相同，
                // 只需比较两单词排序后是否相同即可
                if(Arrays.equals(data,word)){
                    // 兄弟单词和原单词不同，但是可以重复
                    if(!str.equals(target)){
                        broWords.add(str);
                    }
                }
            }

            System.out.println(broWords.size());
            if (broWords.size() >= indext) {
                Collections.sort(broWords);
                System.out.println(broWords.get(indext - 1));
            }
        }
    }
}